//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package messages;

import common.ByteStream;
import common.LogicLong;

public class Login extends Base {
  public static final int MsgType = 10101;
  public int VersionNumber;
  public LogicLong AccountID;
  public String PassToken;
  public String ResourceFingerPrint;
  public int Major;
  public int Build;
  public String UDID;
  public String MacAddress;
  public String Device;
  public int LangDataRef;
  public String Locale;
  public String ADID;
  public String FirmwareVersion;
  public String OpenUDID;
  public String add1;
  public String add2;
  public String add3;
  public String add4;
  public byte add123present = 0;
  public Byte add5;
  public String add6;
  public Integer add7;
  public byte[] sessionKey;
  public byte[] initialEncNonce;
  public Long HomeID = null;
  public String FarmName = null;

  public Login(byte[] loginData) {
    super(10101);
    this.readStream = new ByteStream(loginData);
    this.decode(this.readStream);
  }

  public Login() {
    super(10101);
  }

  public void encode(ByteStream stream) {
    this.encodeHD(stream);
  }

  public void decode(ByteStream stream) {
    this.decodeHD(stream);
    this.isDecoded = true;
  }

  public void partialEncode(ByteStream stream) {
    this.AccountID.encode(stream);
    stream.writeString(this.PassToken);
    stream.writeString(this.ResourceFingerPrint);
    stream.writeInt(this.VersionNumber);
    stream.writeString(this.UDID);
    stream.writeString(this.OpenUDID);
    stream.writeString(this.MacAddress);
    stream.writeString(this.Device);
    stream.writeString(this.ADID);
    stream.writeByte(this.add123present);
    stream.writeString(this.FirmwareVersion);
    if(this.add123present != 0) {
      stream.writeString(this.add1);
      stream.writeString(this.add2);
      stream.writeString(this.add3);
    } else {
      stream.writeInt(0);
      stream.writeInt(0);
      stream.writeString(this.add3);
    }

    if(this.add4.length() > 0) {
      stream.writeString(this.add4);
    } else {
      stream.writeInt(0);
    }

    stream.writeByte(this.add5.byteValue());
    if(this.add6.length() > 0) {
      stream.writeString(this.add6);
    } else {
      stream.writeInt(0);
    }

    if(this.add7 != null) {
      stream.writeInt(this.add7.intValue());
    }

  }

  private void encodeHD(ByteStream stream) {
    stream.writeBytes(this.sessionKey, true);
    stream.writeBytes(this.initialEncNonce, true);
    this.partialEncode(stream);
  }

  private void decodeHD(ByteStream stream) {
    this.AccountID = stream.readLong();
    this.PassToken = stream.readString();
    this.ResourceFingerPrint = stream.readString();
    this.VersionNumber = stream.readInt();
    this.UDID = stream.readString();
    this.OpenUDID = stream.readString();
    this.MacAddress = stream.readString();
    this.Device = stream.readString();
    this.ADID = stream.readString();
    this.add123present = stream.readByte();
    this.FirmwareVersion = stream.readString();
    this.add1 = stream.readString();
    this.add2 = stream.readString();
    this.add3 = stream.readString();
    this.add4 = stream.readString();
    this.add5 = Byte.valueOf(stream.readByte());
    this.add6 = stream.readString();
    if(!stream.isAtEnd()) {
      this.add7 = Integer.valueOf(stream.readInt());
    }

  }

  public String toString() {
    return "AccountID:" + this.AccountID + ", PassToken:" + this.PassToken + ", MsgVer:" + this.VersionNumber + ", Fingerprint:" + this.ResourceFingerPrint;
  }
}
